package com.henu.main.component;

import com.henu.main.executors.*;
import com.henu.main.util.Constant;
import com.henu.main.util.TimeUtil;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@RestController
public class MetricsComponent {

    @Scheduled(cron = "0,10,20,30,40,50 * * * * ? ")
    public void run() throws Exception {

        System.out.println(TimeUtil.getNowTimestamp() + " - " + "Hadoop调度启动");
        int threadCount = 2;
        ExecutorService service = Executors.newFixedThreadPool(threadCount);

//        service.submit(new LastContactExecutor(Constant.HDFS1_URL1, Constant.CLUSTER1));
//        service.submit(new LastContactExecutor(Constant.HDFS1_URL2, Constant.CLUSTER1));
//        service.submit(new LastContactExecutor(Constant.HDFS1_URL3, Constant.CLUSTER1));
//
//        service.submit(new LastContactExecutor(Constant.HDFS2_URL1, Constant.CLUSTER2));
//        service.submit(new LastContactExecutor(Constant.HDFS2_URL2, Constant.CLUSTER2));
//        service.submit(new LastContactExecutor(Constant.HDFS2_URL3, Constant.CLUSTER2));

        service.submit(new KafkaLagExecutor());

        // 销毁线程池
        service.shutdown();

    }

}
